import { getPublicConfig } from '@/api/config'
import type { ConfigTable } from '@/types/config'
import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useConfigStore = defineStore('config', () => {
  let data = ref(new Map<string, ConfigTable>())
  // 异步获取数据
  function getData() {
    getPublicConfig().then((d) => {
      d.data.forEach((c) => {
        data.value.set(c.key, c)
      })
    })
  }
  getData()
  return { data, getData }
})
